#include <linux/fs.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>


struct proc_dir_entry *kblock_proc;


int kblock_proc_open(struct inode *inode,struct file *file);
int kblock_proc_release(struct inode *inode,struct file *file);
const struct file_operations kblock_proc_fops = {
	.owner		= THIS_MODULE,
	.open		= kblock_proc_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= kblock_proc_release,
};



int register_kblock_proc(void)
{
	kblock_proc = proc_create_data("kblock", S_IFREG | S_IRUGO , NULL, &kblock_proc_fops, NULL);
	if (kblock_proc == NULL)	{
		printk(KERN_ERR "drbd: unable to register proc file\n");
		return -1;
	}
	return 0;
}

int unregister_kblock_proc(void)
{
	if (kblock_proc) {
		remove_proc_entry("kblock", NULL);
	}
    return 0;
}

static int kblock_seq_show(struct seq_file *seq, void *v)
{
    seq_printf(seq,"kblock version 1.0.0.0\n");
    return 0;
}

int kblock_proc_open(struct inode *inode,struct file *file)
{
	if (try_module_get(THIS_MODULE))
		return single_open(file, kblock_seq_show, PDE(inode)->data);
	return -ENODEV;
}

int kblock_proc_release(struct inode *inode,struct file *file)
{
	module_put(THIS_MODULE);
	return single_release(inode, file);
}

